Skip to content

feat: external wallet session management#2432

Merged
chaitanyapotti merged 25 commits intomasterfrom
feat/External-wallet-session-management
Apr 6, 2026
Merged

feat: external wallet session management#2432
chaitanyapotti merged 25 commits intomasterfrom
feat/External-wallet-session-management

Conversation

@hieu-w
Copy link
Copy Markdown
Member

@hieu-w hieu-w commented Apr 1, 2026

Jira Link

Description

Fix verifySignedChallenge call in the WalletConnect v2 connector to match the updated VerifySignedChallengeParams interface from @toruslabs/base-controllers.

The baseEvmConnector and baseSolanaConnector were already updated but walletConnectV2Connector was missed:

  • Added missing deviceInfo: getDeviceInfo() parameter (required by VerifySignedChallengeParams)
  • Updated return type handling: verifySignedChallenge now returns SiwwTokens (with idToken, accessToken, refreshToken) instead of a plain string
  • Aligned token handling to use IdentityTokenInfo pattern, matching the other two connectors

How has this been tested?

  • TypeScript type-check passes with no errors
  • Verified the fix matches the existing pattern in baseEvmConnector.ts and baseSolanaConnector.ts

Screenshots (if appropriate)

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • My code follows the code style of this project. (run lint)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Note

High Risk
Changes how external-wallet authentication tokens are fetched, stored, refreshed, and cleared, including new access/refresh token handling and configurable storage adapters; regressions here could break login/authorization flows or leak/retain sessions unexpectedly.

Overview
Adds external wallet session management by replacing getIdentityToken/useIdentityToken with getAuthTokenInfo/useAuthTokenInfo across React/Vue hooks, connectors, and demos, and expanding token handling to include id/access/refresh tokens.

External connectors (EVM, Solana, WalletConnect v2, Coinbase, injected) now use a shared AuthSessionManager-backed flow to cache tokens, refresh access tokens when needed, and best-effort clear sessions on disconnect; the core state is extended to persist accessToken/refreshToken alongside idToken, and SSR token fetching is updated accordingly.

Introduces configurable token storage in IWeb3AuthCoreOptions (storage + cookieOptions) and wires it into the Vue demo UI, while updating dependencies (notably @toruslabs/* controllers and @web3auth/auth) and adding ox where required.

Reviewed by Cursor Bugbot for commit 4d4546c. Bugbot is set up for automated code reviews on this repo. Configure here.

@hieu-w hieu-w requested review from a team as code owners April 1, 2026 05:47
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web3auth-web Ready Ready Preview, Comment Apr 6, 2026 8:19am

Request Review

@hieu-w hieu-w changed the title Feat/external wallet session management feat: external wallet session management Apr 1, 2026
Copy link
Copy Markdown
Member

@chaitanyapotti chaitanyapotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should use the AuthSessionManager to manage the session here and not write custom saving of tokens.

ethereumProvider: this.provider,
solanaWallet: this._solanaWallet,
identityTokenInfo,
authTokenInfo,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authTokenInfo here is undefined value? In Line 439, we just initialized the value with undefined only.

Should we move this emit to after we called await this.getAuthTokenInfo();?

ethereumProvider: this.provider,
solanaWallet: null,
identityTokenInfo,
authTokenInfo,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here as above.

const userInfo = await this.getUserInfo();
this.status = CONNECTOR_STATUS.AUTHORIZED;
this.emit(CONNECTOR_EVENTS.AUTHORIZED, { connector: WALLET_CONNECTORS.AUTH, identityTokenInfo: { idToken: userInfo.idToken as string } });
this.emit(CONNECTOR_EVENTS.AUTHORIZED, { connector: WALLET_CONNECTORS.AUTH, authTokenInfo: { idToken: userInfo.idToken as string } });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should return access and refresh token from auth sdk as well

@chaitanyapotti chaitanyapotti merged commit dc28287 into master Apr 6, 2026
7 checks passed
@chaitanyapotti chaitanyapotti deleted the feat/External-wallet-session-management branch April 6, 2026 08:21
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 4d4546c. Configure here.

chainNamespace,
signedMessage as string,
challenge,
this.name,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EVM/Solana connectors never clean up auth sessions on disconnect

Medium Severity

The disconnect() method in BaseEvmConnector and BaseSolanaConnector never calls clearWalletSession(), so AuthSessionManager session tokens persist in storage after disconnect. The walletConnectV2Connector correctly calls await this.clearWalletSession() in its disconnect() override, creating an inconsistency. The disconnectSession() method that does call clearWalletSession() appears to be dead code — it's defined but never invoked from disconnect(), noModal.logout(), or anywhere else reachable in the call graph.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4d4546c. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants